# -*- coding: utf-8 -*-
from time import sleep

import allure
from common.page import Page
from regression_service_rdc.funtion.fun_main_rdc import MainRdc
from regression_service_rdc.page_elements.el_login_rdc import login_rdc


class LoginRdc:
    @allure.step('step:输入账号')
    def sendkeys_usename(self, data):
        Page.send_key(login_rdc, '登录', '账号', data)
        return LoginRdc()

    @allure.step('step:输入密码')
    def sendkeys_password(self, data):
        Page.send_key(login_rdc, '登录', '密码', data)
        return LoginRdc()

    @allure.step('step:点击登录')
    def click_login(self):
        Page.move_to_element(login_rdc, '登录', '授权并登录')
        Page.click(login_rdc, '登录', '授权并登录')
        return MainRdc()

    def login(self, username, password):
        self.sendkeys_usename(username)
        self.sendkeys_password(password)
        self.click_login()
        return MainRdc()
